var status = 0;
var item = 
Array(     

			Array(1032004,888,0), //金耳环
			Array(1032005,888,0), //红十字耳环
			Array(1032006,888,0), //雷电耳环
			Array(1032007,888,0), //祖母綠耳环
			Array(1032008,888,0), //猫眼耳环
			Array(1032009,888,0), //黄方耳环
			Array(1002019,888,0), //白头巾
			Array(1002020,888,0), //红星头巾
			Array(1002021,888,0), //诺曼头盔
			Array(1002022,888,0), //旧诺曼头盔
			Array(1002023,888,0), //枪骑士头盔
			Array(1002024,888,0), //祖母綠武士头盔
			Array(1002030,888,0), //银制战帽
			Array(1002033,888,0), //狗皮帽
			Array(1002039,888,0), //青铜头盔
			Array(1002040,888,0), //锂矿帽
			Array(1002041,888,0), //黄色金属头箍
			Array(1002246,888,0), //黑和平之帽
			Array(1002247,888,0), //青铜忍者头巾
			Array(1002248,888,0), //银忍者头巾
			Array(1002249,888,0), //黑忍者头巾
			Array(1002252,888,0), //红神圣之冠
			Array(1002253,888,0), //蓝神圣之冠
			Array(1002254,888,0), //黑神圣之冠
			Array(1002267,888,0), //赤弓羽
			Array(1002268,888,0), //黄弓羽
			Array(1002269,888,0), //白弓羽
			Array(1002270,888,0), //黑弓羽
			Array(1002271,888,0), //绿十字帽
			Array(1102000,888,0), //绿色冒险披风
			Array(1102001,888,0), //蓝色冒险披风
			Array(1102002,888,0), //红色冒险披风
			Array(1102003,888,0), //白色冒险披风
			Array(1102004,888,0), //黑色冒险披风
			Array(1102011,888,0), //蓝色守护披风
			Array(1082015,888,0), //绿狩猎手套
			Array(1082016,888,0), //蓝命中手套
			Array(1082017,888,0), //红命中手套
			Array(1082018,888,0), //黑命中手套
			Array(1082019,888,0), //魔法手套
			Array(1082020,888,0), //蓝色梅林手套
			Array(1082021,888,0), //绿色梅林手套
			Array(1082022,888,0), //紫色梅林手套
			Array(1082023,888,0), //钢铁指节手套
			Array(1082024,888,0), //朱矿指节手套
			Array(1082025,888,0), //黑指节手套
			Array(1082026,888,0), //蓝贤者手套
			Array(1302016,888,0), //黄色雨伞
			Array(1302017,888,0), //蓝色雨伞
			Array(1302018,888,0), //汤勺
			Array(1302019,888,0), //无名剑
			Array(1302020,888,0), //枫叶战剑
			Array(1302021,888,0), //橡皮榔头
			Array(1302022,888,0), //竹刀
			Array(1302023,888,0), //六脉神剑
			Array(1302024,555,0), //废报纸卷
			Array(1302025,888,0), //红雨伞
			Array(1302026,555,0), //黑雨伞
			Array(1302027,888,0), //绿雨伞
			Array(1302028,888,0), //紫雨伞
			Array(1302029,888,0), //褐雨伞
			Array(1302030,300,0), //枫叶剑
			Array(1302031,888,0), //七星剑
			Array(1332000,888,0), //三角刃
			Array(1332001,888,0), //半月刃
			Array(1332002,888,0), //三指刃
			Array(1332003,888,0), //破碎刃
			Array(1332004,888,0), //双枝短刀
			Array(1332005,888,0), //刮胡刀
			Array(1332006,888,0), //战斗短刀
			Array(1332007,888,0), //短刀
			Array(1332008,888,0), //牙刀
			Array(1332009,888,0), //偃月刃
			Array(2040017,800,0), //头盔命中率卷轴60%
			Array(2040014,800,0), //头盔命中率诅咒卷轴70% 
			Array(2040013,800,0), //头盔智力卷轴30
			Array(2040012,800,0), //头盔智力卷轴70
			Array(2040105,800,0), //脸部装饰回避率卷轴10%
			Array(2040106,800,0), //脸部装饰回避率卷轴60%
			Array(2040108,800,0), //脸部装饰回避率诅咒卷轴30% 
			Array(2040109,800,0), //脸部装饰回避率诅咒卷轴70% 
			Array(2040200,800,0), //眼部装饰命中率卷轴10%
			Array(2040201,800,0), //眼部装饰命中率卷轴60%
			Array(2040203,800,0), //眼部装饰命中率诅咒卷轴30% 
			Array(2040204,800,0), //眼部装饰命中率诅咒卷轴70%
			Array(2040205,800,0), //眼部装饰智力卷轴10%
			Array(2040206,800,0), //眼部装饰智力卷轴60%
			Array(2040208,800,0), // 眼部装饰智力诅咒卷轴30%
			Array(2040209,800,0), //眼部装饰智力诅咒卷轴70%			
			Array(2040301,800,0), //耳环智力卷轴 60
			Array(2040302,800,0), //耳环智力卷轴 10
			Array(2040303,100,1), //耳环智力诅咒卷轴必成
			Array(2040304,800,0), //耳环智力诅咒卷轴70
			Array(2040305,800,0), //耳环智力诅咒卷轴30
			Array(2040306,800,0), //耳环敏捷卷轴70
			Array(2040307,800,0), //耳环敏捷卷轴30
                        Array(2040406,800,0), //上衣力量卷轴70%
			Array(2040407,800,0), //上衣力量卷轴30
			Array(2040410,800,0), //上衣运气诅咒卷轴70%
			Array(2040411,800,0), //上衣运气诅咒卷轴30%
			Array(2040501,800,0), //全身铠甲敏捷卷轴60
			Array(2040506,100,1), //全身铠甲敏捷卷轴(必成)
			Array(2040509,800,0), //全身铠甲敏捷卷轴30
			Array(2040513,800,0), //全身铠甲智力卷轴60
			Array(2040518,800,0), //全身铠甲智力卷轴70
			Array(2040519,800,0), //全身铠甲智力卷轴30
			Array(2040610,800,0), //裤裙敏捷诅咒卷轴70
			Array(2040611,800,0), //裤裙敏捷诅咒卷轴30
			Array(2040613,800,0), //裤裙敏捷卷轴60%
			Array(2040704,800,0), //鞋子跳跃卷轴60
			Array(2040705,800,0), //鞋子跳跃卷轴10
			Array(2040710,100,1), //鞋子跳跃卷轴(必成)
			Array(2040715,800,0), //鞋子跳跃卷轴30
			Array(2040804,800,0), //手套攻击卷轴60
			Array(2040811,800,0), //手套攻击卷轴30
			Array(2040810,800,0), //手套攻击卷轴70
			Array(2040807,100,1), //手套攻击卷轴(必成)
			Array(2040805,800,0), //手套攻击卷轴10
			Array(2040816,800,0), // 手套魔力卷轴10%
			Array(2040817,800,0), //手套魔力卷轴60%
			Array(2040815,800,0), //手套魔力卷轴30%
			Array(2040922,800,0), //盾牌魔力诅咒卷轴30%
			Array(2040919,800,0), //盾牌魔力诅咒卷轴60%
			Array(2040921,800,0), //盾牌魔力诅咒卷轴70%
			Array(2040914,800,0), // 盾牌攻击卷轴60%
			Array(2040916,700,0), //盾牌攻击卷轴70%
			Array(2040917,700,0), //盾牌攻击诅咒卷轴30%
			Array(2041013,900,0), //披风力量卷轴60
			Array(2041016,900,0), //披风智力卷轴60
			Array(2041019,900,0), //披风敏捷卷轴60
			Array(2041022,800,0), //披风运气卷轴60
			Array(2041200,100,0), //暗黑龙王石
			Array(2043005,800,0), //单手剑攻击诅咒卷轴30
			Array(2043003,100,1), //单手剑攻击诅咒卷轴(必成)
			Array(2044005,800,0), //双手剑攻击诅咒卷轴30
			Array(2044003,100,1), //双手剑攻击诅咒卷轴(必成)
			Array(2044305,800,0), //枪攻击诅咒卷轴30
			Array(2044303,100,1), //枪攻击诅咒卷轴(必成)
			Array(2044405,800,0), //矛攻击诅咒卷轴30
			Array(2044403,100,1), //矛攻击诅咒卷轴(必成)
			Array(2044503,100,1), //弓攻击诅咒卷轴(必成)
			Array(2044505,800,0), //弓攻击诅咒卷轴30
			Array(2044605,800,0), //弩攻击诅咒卷轴30
			Array(2044603,200,1), //弩攻击诅咒卷轴(必成)
			Array(2044705,800,0), //拳套攻击诅咒卷轴30
			Array(2044703,100,1), //拳套攻击诅咒卷轴(必成)		
			Array(1402014,100,1), //温度计			
			Array(1442018,60,1), //冻冻鱼
			Array(1442024,300,0), //枫叶矛
			Array(1442025,300,0), //青龙偃月刀
			Array(1442039,300,1), //冻冻鱼
			Array(1442045,300,0), //血龙神斧
			Array(1442046,300,0), //超级滑雪板
			Array(1442053,300,0), //粉色花边游泳圈
			Array(1442054,300,0), //红色滑水板
			Array(1442055,300,0), //绿色滑水板
			Array(1442056,300,0), //蓝色滑水板
			Array(1442057,300,0), //紫色滑水板
			Array(1442063,10,0), //永恒神光戟
			Array(1442065,300,0), //蓝色冲浪板
			Array(1442066,300,0), //红色冲浪板
			Array(1442067,10,0), //重生神光戟
			Array(1442069,300,0), //红色冲浪板
			Array(1442070,300,0), //绿色冲浪板
			Array(1452044,300,0), //金龙振翅弓
			Array(1452057,50,1), //永恒惊电弓
			Array(1452059,50,1), //重生惊电弓
			Array(1452062,50,1), //圣诞六翼天使武器(弓)
			Array(1462050,50,1), //永恒冥雷弩
			Array(1462051,50,1), //重生冥雷弩
			Array(1462056,50,1), //圣诞六翼天使武器(弩)
			Array(1472068,50,1), //永恒大悲赋
			Array(1472071,50,1), //重生大悲赋
			Array(1472077,50,1), //圣诞六翼天使武器(拳套)
			Array(1472054,500,0), //信玄
			Array(1482023,50,0), //永恒孔雀翎
			Array(1482024,50,0), //重生孔雀翎
			Array(1492023,50,0), //永恒凤凰铳
			Array(1492025,50,0), //重生凤凰铳			
			Array(1082145,500,1), //工地手套(黄)
			Array(1082146,500,1), //工地手套(红)
			Array(1082147,500,1), //工地手套(蓝)
			Array(1082148,500,1), //工地手套(紫)
			Array(1082149,500,1), //工地手套(褐)
			Array(1082150,500,1), //工地手套(灰)
			Array(1102172,100,0), //永恒不灭披风
			Array(1102040,700,1), //浪人披风(黄)
			Array(1102041,700,1), //浪人披风(粉)
			Array(1102042,700,1), //浪人披风(紫)
			Array(1102043,700,1), //浪人披风(褐)
			Array(1002776,100,0), //永恒冠军盔
			Array(1002777,100,0), //永恒玄妙帽
			Array(1002778,100,0), //永恒霓翎帽
			Array(1002779,100,0), //永恒迷踪帽
			Array(1002780,100,0), //永恒海王星
			Array(1002790,100,0), //重生冠军盔
			Array(1002791,100,0), //重生玄妙帽
			Array(1002792,100,0), //重生霓翎帽
			Array(1002793,100,0), //重生迷踪帽
			Array(1002794,100,0), //重生海王星
			Array(1002723,300,1), //月饼帽
			Array(1002080,500,0), //红头巾
			Array(1002081,500,0), //青头巾
			Array(1002082,500,0), //黄头巾
			Array(1002083,500,0), //黑头巾
			Array(1002033,500,0), //狗皮帽
			Array(1132004,200,1), //黑贺腰带
			Array(1122000,80,1), //黑龙项环
			Array(1092045,500,0), //冒险岛魔法师盾牌
			Array(1032026,500,1), //黄水晶耳环
			Array(1072238,500,1), //紫色钉鞋
			Array(1072239,500,1), //黄色钉鞋
			Array(1102084,300,0), //粉红盖亚披风
			Array(1132013,300,1), //不灭的法老腰带
			Array(1002418,700,1), //废报纸头盔
			Array(1302058,700,1), //冒险岛伞
			Array(1302063,500,1), //燃烧的火焰刀
			Array(1302061,550,1), //蔓藤鞭子			
			Array(2101132,700,0), //七色彩蛋包
			Array(2101118,700,0), //舞狮怪物包
			Array(1122003,700,0), //黄色蝶型领结
			Array(2022141,800,0), //震魂包子
			Array(2022176,900,0), //超级药水
			Array(2022245,800,0), //心跳停止糖
			Array(2100103,700,0), //武陵道场召唤包_萧公
			Array(1092008,750,0), //锅盖
			Array(1022047,600,1), // 猫头鹰
			Array(1022060,600,1), //狐猴
			Array(1022058,600,1), //狸猫
			Array(1122012,80,1), //永恒玉佩 
			Array(1032035,300,1), //枫叶耳环
			Array(1032058,200,1), //工作人员C钛质收信机
			Array(2340000,299,1), //祝福卷
			Array(3010007,80,1), //粉色海狗靠垫
			Array(3010008,80,1), //蓝色海狗靠垫
			Array(3010009,200,1), //榻榻凳
			Array(3010010,80,1), //白玉海豹靠垫
			Array(3010016,80,1), //黑色海狗靠垫
			Array(3010017,80,1), //金色海狗靠垫
			Array(3010024,20,1), //玩具粉熊椅
			Array(3010034,20,1), //悠长假期(红色)
			Array(3010035,20,1), // 悠长假期(蓝色)
			Array(3010036,9,0), //浪漫秋千
			Array(3010041,50,1), //蝙蝠椅
			Array(3010043,10,1), //魔女的飞扫把
			Array(3010007,20,1), //寒冰椅子
			Array(3010046,20,1), //红龙椅
			Array(3010047,20,1), //蓝龙椅 
			Array(3010048,50,1), //圣诞树椅子
			Array(3010049,50,1), //雪房子
			Array(3010050,50,1), //公主椅子
			Array(3010051,15,1), //沙漠兔子1靠垫
			Array(3010052,10,1), //沙漠兔子2靠垫
			Array(3010057,50,1), //血色玫瑰
			Array(3010058,50,1), //世界末日
			Array(3010068,50,1), //露水椅子
			Array(3010070,50,1), //巨无霸品克缤
			Array(3010071,50,1), //神兽椅
			Array(3010075,50,1), //我为音乐狂
			Array(3010077,50,1), //猫头鹰椅子
			Array(3010093,50,1), //鲜美的火鸡
			Array(3010098,500,1), //电视宅人
			Array(3010099,50,1), //北极熊椅子
			Array(3010106,50,1), // 雪狼战椅
			Array(3012006,50,1), //风吹稻香
			Array(3012010,50,1), //巧克力蛋糕恋人
	              Array(3010013,20,1), //悠长假期
			Array(3010014,20,1), //月亮弯
			Array(3010018,20,1), //椰子树沙滩椅
			Array(3010019,200,1), //寿司椅
			Array(3010021,50,1), //暖暖桌
			Array(3010025,20,1), //枫叶纪念凳
			Array(3010028,40,1), //海盗的俘虏
			Array(3010029,50,1), //蓝环凳
			Array(3010030,50,1), //黑环凳
			Array(3010031,50,1), //红环凳
			Array(3010032,50,1), //黄环凳
			Array(3010033,50,1), //绿环凳
			Array(3010037,50,1), //亲亲嘴凳
			Array(3010044,50,1), //同一红伞下
			Array(3012001,50,1), //篝火
			Array(3012002,50,1), //浴桶
			Array(3010073,50,1), //PB克缤
			Array(3012003,50,1) //爱心椅子
);

function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0) {
			cm.dispose();
			return;
		}
		if (mode == 1)
			status++;
		else
			status--;
		if (status == 0) {
			if (cm.haveItem(5220040)) {
				cm.sendYesNo("欢迎参加本次系统活动。使用飞天猪的蛋你可获得异想不到的物品！系统会随机抽取物品， 是否继续使用飞天猪的迷之蛋进行抽奖？");
			} else {
				cm.sendOk("欢迎参加本次系统活动。你确定有飞天猪的蛋吗？");
				cm.dispose();
			}
		} else if (status == 1){	
			var ii = net.sf.cherry.server.MapleItemInformationProvider.getInstance();
			for(var i = 1;i<=5;i++){
				if(cm.getPlayer().getInventory(net.sf.cherry.client.MapleInventoryType.getByType(i)).isFull()){
					cm.sendOk("您至少应该让所有包裹都空出一格");
					cm.dispose();
					return;
				}
			}
			var chance = Math.floor(Math.random()*1000);
			var finalitem = Array();
			for(var i = 0 ;i<item.length;i++){
				if(item[i][1] >= chance){
					finalitem.push(item[i]);
				}
			}
			if(finalitem.length != 0){
				var random = new java.util.Random();
				var finalchance = random.nextInt(finalitem.length);
				var itemId = finalitem[finalchance][0];
				var Laba = finalitem[finalchance][2];
			      if(ii.getInventoryType(itemId).getType() == 1){
			        	var toDrop = ii.randomizeStats(ii.getEquipById(itemId)).copy();
				}
				else{
				 	 var toDrop = new net.sf.cherry.client.Equip(itemId,0).copy();
				}				
				net.sf.cherry.server.MapleInventoryManipulator.addFromDrop(cm.getC(), toDrop, -1);
				if(Laba == 1){
					cm.getC().getChannelServer().getWorldInterface().broadcastMessage(null, net.sf.cherry.tools.MaplePacketCreator.getItemMega(cm.getC().getChannel(),cm.getPlayer().getName() + " : " + "从飞天猪获得！大家一起恭喜他（她）吧！！！",toDrop, true).getBytes());
				}
				cm.gainItem(5220040,-1);
				cm.getPlayer().saveToDB(true);
				cm.sendOk("非常感谢参加本次系统活动。多多努力。获取更多的礼物吧！");
				cm.dispose();
			} else {							
				cm.gainItem(5220040,-1);
				cm.gainItem(2022140,1);
				cm.getPlayer().saveToDB(true);
				cm.sendOk("非常感谢参加本次系统活动。多多努力。获取更多的礼物吧！");
				cm.dispose();
			}
		}
	}
}
